<?php

namespace Lowpress\PressBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="lowpress_tag")
 */
class Tag {

  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;


  /**
   * @ORM\Column(type="string",length=64)
   */
  private $name;

  /**
  * @ORM\ManyToMany(targetEntity="Item", mappedBy="tags")
  */
  private $items;



  public function __construct()
  {
    $this->items = new \Doctrine\Common\Collections\ArrayCollection();
  }


  /**
   * Get id
   *
   * @return integer $id
   */
  public function getId()
  {
      return $this->id;
  }

  /**
   * Get name
   *
   * @return string $name
   */
  public function getName()
  {
    return $this->name;
  }

  /**
   * Set name
   *
   * @param string $name
   */
  public function setName($name)
  {
    $this->name = strtolower($name);
    return $this;
  }

  public function addItem(Item $item)
  {
    $this->items[] = $item;
  }
}

